from pydantic import AnyHttpUrl
from fastapi import FastAPI
from pydantic_settings import BaseSettings
from pydantic.networks import IPvAnyAddress
from typing import Any
from EventNotifier import Notifier

IS_DEV = True  # 是否开发环境

class Settings(BaseSettings):
   
    PROJECT_NAME: str = "AiReptile"  # 项目名称 必填
    PROJECT_DESC: str = "🎉 接口汇总 🎉"  # 描述
    PROJECT_VERSION: int | str = 1.0  # 版本
    API_PREFIX: str = "/api/v1"  # 接口前缀

    APP_NAME: str = "main:app"
    HOST: str = "0.0.0.0"     # 允许访问程序的ip， 只允许本地访问使用 127.0.0.1， 只在直接允许程序时候生效
    PORT: int = 8000    # 程序端口，只在直接运行程序的时候生效
    RELOAD: bool = True     # 是否自动重启，只在直接运行程序时候生效

    CORS_ORIGINS: list[str] = ['*']  # 跨域请求(务必指定精确ip, 不要用localhost)
    MOUNT_LOCATION: str = '/ws'  

    STATIC_DIR: str = "static"  # 静态文件目录
    BASE_URL: AnyHttpUrl = "http://127.0.0.1:8000"  # 开发环境(为了存放图片全路径)


class DevelopmentConfig(Settings):
    pass

class ProductionConfig(Settings):
    BASE_URL: AnyHttpUrl = "http://114.115.143.81:8000"  # 生产环境(为了存放图片全路径)
    CORS_ORIGINS: list[AnyHttpUrl] = ["http://114.115.143.81"]  # 跨域请求

    # REDIS_URI: str = "redis://:123456@redis:6379/0"  # Redis
    # DATABASE_URI: str = "mysql://root:123456@mysql:3306/demo?charset=utf8"  # MySQL
    # DATABASE_ECHO: bool = True  # 是否打印数据库日志 (可看到创建表、表数据增删改查的信息)

    # LOGGER_LEVEL: str = 'INFO'  # 日志等级: ['DEBUG' | 'INFO']


appInatanc: FastAPI
settings = DevelopmentConfig() if IS_DEV else ProductionConfig()